package com.finger.forest.adapter;

import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.finger.forest.R;
import com.finger.forest.model.CollectionRoadModel;
import com.makeramen.roundedimageview.RoundedImageView;

import java.util.List;

/**
 * @author sy
 * @date 2021/1/20
 * @desc
 */
public class SynchronizationDataAdapter extends BaseQuickAdapter<CollectionRoadModel, BaseViewHolder> {
    public SynchronizationDataAdapter(int layoutResId, @Nullable List<CollectionRoadModel> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, CollectionRoadModel item) {


        RoundedImageView rivSynchronization = helper.getView(R.id.rivSynchronization);

        CheckBox cbNotice = helper.getView(R.id.cbDataSynchronization);
        //是否选中
        cbNotice.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    item.setSelect(true);
                } else {
                    item.setSelect(false);
                }
            }
        });

        TextView tvName = helper.getView(R.id.tvName);
        String title = "";
        switch (item.getType()) {
            //1道路采集 2巡护采集 3资源 4火场  5小班
            case 1:
                title = "道路采集";
                rivSynchronization.setBackgroundResource(R.mipmap.icon_road);
                break;

            case 2:
                title = "巡护采集";

                break;

            case 3:
                title = "资源采集";
                rivSynchronization.setBackgroundResource(R.mipmap.icon_resources);
                break;
            case 4:
                title = "火场采集";
                rivSynchronization.setBackgroundResource(R.mipmap.icon_site_of_a_fire);
                break;
            case 5:
                title = "小班采集";
                break;
            default:
                break;
        }
        tvName.setText(title);
    }
}
